/**
 * @project_name staff_vehicle
 * @package_name com.ssh.web.admin
 * @desc TODO
 * @param
 * @author jack
 * @date 2013-5-1
 * @time 上午7:26:33
 */
package com.ssh.web.admin;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.ssh.model.pdata.StaffAMPData;
import com.ssh.model.pdata.StaffDepApplyCarMData;
import com.ssh.ser.admin.DispatchVDMSerI;

/**
 * @author jack
 * @desc 给申请用车人员 分配车辆Action
 */
public class DispatchVMAction extends ActionSupport {
	/**
	 * TODO
	 */
	private static final long serialVersionUID = 1L;
	private DispatchVDMSerI dispatchVDMSerI;
	private String driverId;
	private String idWhoApply;
	private String idWhoUseCar;
	private List<StaffDepApplyCarMData> staffAMPDataList;
	private int idstaffApplyCar ;
	
	private String vehicleId;

	public int getIdstaffApplyCar() {
		return idstaffApplyCar;
	}

	public void setIdstaffApplyCar(int idstaffApplyCar) {
		this.idstaffApplyCar = idstaffApplyCar;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		return viewWWToApplyCar();
	}

	/**
	 * @return the dispatchVDMSerI
	 */
	public DispatchVDMSerI getDispatchVDMSerI() {
		return dispatchVDMSerI;
	}

	/**
	 * @return the driverId
	 */
	public String getDriverId() {
		return driverId;
	}

	/**
	 * @return the idWhoApply
	 */
	public String getIdWhoApply() {
		return idWhoApply;
	}

	/**
	 * @return the idWhoUseCar
	 */
	public String getIdWhoUseCar() {
		return idWhoUseCar;
	}

	/**
	 * @return the staffAMPDataList
	 */
	public List<StaffDepApplyCarMData> getStaffAMPDataList() {
		return staffAMPDataList;
	}

	/**
	 * @return the vehicleId
	 */
	public String getVehicleId() {
		return vehicleId;
	}

	public String iAgreeDispatch() {
		try {
			System.out.println(idWhoApply+idWhoUseCar+vehicleId+driverId);
			dispatchVDMSerI.agreeDVDriver(idWhoApply, idWhoUseCar, vehicleId,driverId);
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
		return "agreeApply";
	}

	public String iDisAgreeDispatch() {
		try {
			dispatchVDMSerI.declineDVDriver(idstaffApplyCar);
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}
		return "disagree";
	}

	/**
	 * @param dispatchVDMSerI
	 *            the dispatchVDMSerI to set
	 */
	public void setDispatchVDMSerI(DispatchVDMSerI dispatchVDMSerI) {
		this.dispatchVDMSerI = dispatchVDMSerI;
	}

	/**
	 * @param driverId
	 *            the driverId to set
	 */
	public void setDriverId(String driverId) {
		this.driverId = driverId;
	}

	/**
	 * @param idWhoApply
	 *            the idWhoApply to set
	 */
	public void setIdWhoApply(String idWhoApply) {
		this.idWhoApply = idWhoApply;
	}

	/**
	 * @param idWhoUseCar
	 *            the idWhoUseCar to set
	 */
	public void setIdWhoUseCar(String idWhoUseCar) {
		this.idWhoUseCar = idWhoUseCar;
	}

	/**
	 * @param staffAMPDataList
	 *            the staffAMPDataList to set
	 */
	public void setStaffAMPDataList(List<StaffDepApplyCarMData> staffAMPDataList) {
		this.staffAMPDataList = staffAMPDataList;
	}

	/**
	 * @param vehicleId
	 *            the vehicleId to set
	 */
	public void setVehicleId(String vehicleId) {
		this.vehicleId = vehicleId;
	}

	/**
	 * 查看某位员工申请用车的信息
	 */
	public String viewOneApplyCar() {
		try {
			staffAMPDataList = dispatchVDMSerI.viewOneWaitingApply(idWhoApply,
					idWhoUseCar, "waiting");
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}

		return "oneApply";
	}

	/**
	 * 查看所有的申请用车的信息
	 */
	public String viewWWToApplyCar() {
		try {
			staffAMPDataList = dispatchVDMSerI.viewWhoWToApply();
		} catch (Exception e) {
			e.printStackTrace();
			return "error";
		}

		return "wWantToApply";
	}

}
